package com.powernode.springboot.controller;

import com.powernode.springboot.model.Vip;
import com.powernode.springboot.service.VipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class VipController
{
    @GetMapping(value ={ "/","/vip"})
    public String toVip(){
        return "vip";
    }
    @Autowired
    private VipService vipService;


    @GetMapping("/vip/{id}")
    public String detailById(@PathVariable("id") Long id, Model model){
        Vip vip = vipService.getVipById(id);
        model.addAttribute("vip", vip);
        System.out.println(vip);
        return "vipDetail";
    }
}
